package com.example.expression;

import com.example.domain.LoginUser;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

/**
 * 自定义权限实现
 */
@Component
public class ExpressionRoot {

    public boolean hasAuthority(String authority) {
        // 获取当前用户权限
        LoginUser permissions = (LoginUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        return permissions.getPermissions().contains(authority);
    }

}
